using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication2.Models.Mapping
{
    public class AcctOpeningMap : EntityTypeConfiguration<AcctOpening>
    {
        public AcctOpeningMap()
        {
            // Primary Key
            this.HasKey(t => t.ID);

            // Properties
            this.Property(t => t.Acct)
                .IsRequired()
                .HasMaxLength(40);

            this.Property(t => t.File_Primary_Key)
                .HasMaxLength(10);

            this.Property(t => t.Partyid)
                .HasMaxLength(10);

            // Table & Column Mappings
            this.ToTable("AcctOpening");
            this.Property(t => t.ID).HasColumnName("ID");
            this.Property(t => t.Acct).HasColumnName("Acct");
            this.Property(t => t.CstctrID).HasColumnName("CstctrID");
            this.Property(t => t.Year).HasColumnName("Year");
            this.Property(t => t.OpenAcctDR).HasColumnName("OpenAcctDR");
            this.Property(t => t.OpenAcctCR).HasColumnName("OpenAcctCR");
            this.Property(t => t.OpenBase1DR).HasColumnName("OpenBase1DR");
            this.Property(t => t.OpenBase1CR).HasColumnName("OpenBase1CR");
            this.Property(t => t.OpenBase2DR).HasColumnName("OpenBase2DR");
            this.Property(t => t.OpenBase2CR).HasColumnName("OpenBase2CR");
            this.Property(t => t.File_Primary_Key).HasColumnName("File Primary Key");
            this.Property(t => t.Partyid).HasColumnName("Partyid");
            this.Property(t => t.Classification).HasColumnName("Classification");

            // Relationships
            this.HasRequired(t => t.Acct1)
                .WithMany(t => t.AcctOpenings)
                .HasForeignKey(d => d.Acct);
            this.HasRequired(t => t.Cstctr)
                .WithMany(t => t.AcctOpenings)
                .HasForeignKey(d => d.CstctrID);

        }
    }
}
